package example.chapter7;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class FileListAction extends ActionSupport{
	private List<File> listFile = new ArrayList<File>();
	private String basePath;
	
	public String execute() throws Exception{
		basePath = getText("path.download_base");
		File dir = new File(basePath);
		File[] files = dir.listFiles();
		
		if(null != files){
			for(File f: files){
				if(f.isFile()){
					listFile.add(f);
				}
			}
		}
		
		return SUCCESS;
	}

	public List<File> getListFile() {
		return listFile;
	}

	public void setListFile(List<File> listFile) {
		this.listFile = listFile;
	}

	public String getBasePath() {
		return basePath;
	}

	public void setBasePath(String basePath) {
		this.basePath = basePath;
	}
	
}
